//
//  MainViewController.swift
//  ClassFiveWeiBO
//
//  Created by wujunjie on 2017/1/8.
//  Copyright © 2017年 wujunjie. All rights reserved.
//

import UIKit
//Mark -LifeStyle
class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
    }
}
//MARK -设置 UI
extension MainViewController{
    
    func setupUI(){
        addViewControllers()
    }
    
    func addViewControllers(){
        let homeVC = HomeViewController()
        addChildViewController(homeVC, title: "首页", imageName:"tabbar_home")
        
        let discoverVC = DiscoverViewController()
        addChildViewController(discoverVC, title: "发现", imageName:"tabbar_discover")
        
        let messageVc = MessageViewController()
        addChildViewController(messageVc, title: "消息", imageName:"tabbar_message_center")
        
        let profileVC = ProfilerViewController()
        addChildViewController(profileVC, title: "我", imageName:"tabbar_profile")
    }
    
    func addChildViewController(controller: UIViewController,title:String,imageName:String)
    {
        
        let nav = UINavigationController(rootViewController: controller)
        
        controller.title = title
        controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.darkGrayColor(),NSFontAttributeName:UIFont.systemFontOfSize(13.0)], forState: .Normal)
        controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor(),NSFontAttributeName:UIFont.systemFontOfSize(13.0)], forState: .Selected)
        
        controller.tabBarItem.image = UIImage(named: imageName)?.imageWithRenderingMode(.AlwaysOriginal)
        controller.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")?.imageWithRenderingMode(.AlwaysOriginal)
        addChildViewController(nav)
    }
}